 // IM初始化
 window.JIM = new JMessage({
         // debug : true
     });
 	$.ajax({
 	url:'http://liuqingwushui.top/api/imchat.php',
 	data:{},
 	success:function(data){
 	JIM.init({
 		"appkey" : data.appkey,
 		"random_str" : data.random_str,
 		"signature" : data.signature,
 		"timestamp" : data.timestamp,
 		"flag" : 0
 	}).onSuccess(function(data) {
 		console.log('success:' + JSON.stringify(data));
 	}).onFail(function(data) {
 		console.log('error:' + JSON.stringify(data))
 		 });
 		},
 		error:function(data){
 			mui.alert("鉴权失败");
 		}
 			});
 
  function login() {
		var user=$('#user').val();
		var pass=$("#pass").val();
		if(user!=''&&pass!=''){
        JIM.login({
            'username' : user,
			'password': pass
        }).onSuccess(function(data) {
            console.log(data);
			localStorage.setItem("account", user);
			localStorage.setItem("pass", pass);
			window.location.href="main.html";
        }).onFail(function(data) {
			 mui.alert(data.message);
        }).onTimeout(function(data) {
            mui.alert("连接超时");
        });}else{
			mui.alert("账号或密码不能为空");
		}
    }
function regis(){
	var name=$("#rname").val();
	var ruser=$("#ruser").val();
	var rpass=$("#rpass").val();
	var remail=$('#remail').val();
	if(name!=''&&ruser!=''&&rpass!=''&&remail!=''){
		 JIM.register({
				'nickname' : name,
		        'username' : ruser,
		        'password' : rpass,
		          'extras' : {'email':remail},
		        }).onSuccess(function(data) {
		            //data.code 返回码
		            //data.message 描述
					mui.alert("注册成功");
		          }).onFail(function(data) {
		            // 同上
					mui.alert("注册失败");
		        });
	}else{
		mui.alert("不能为空");
	}
	
}